package com.ph.irp.base.materialassistantattribute.action;

import java.util.List;

import com.ph.irp.base.materialassistantattribute.service.AssistantAttributeService;
import com.ph.irp.base.materialassistantattribute.service.AssistantAttributeTypeService;
import com.ph.irp.model.PBaseMaterialAssistantattribute;
import com.ph.irp.model.PBaseMaterialAssistantattributetype;

public class AssistantAttributeAction {
	private String FORWARD = null;
	private AssistantAttributeService attributeService;
	private AssistantAttributeTypeService attributeTypeService;
	private PBaseMaterialAssistantattribute attributeModel;
	private String[] rowlist;
	private List<PBaseMaterialAssistantattribute> list;
	private PBaseMaterialAssistantattributetype typeModel;
	private int assistantAttributeTypeId;

	public int getAssistantAttributeTypeId() {
		return assistantAttributeTypeId;
	}

	public void setAssistantAttributeTypeId(int assistantAttributeTypeId) {
		this.assistantAttributeTypeId = assistantAttributeTypeId;
	}

	public PBaseMaterialAssistantattributetype getTypeModel() {
		return typeModel;
	}

	public void setTypeModel(PBaseMaterialAssistantattributetype typeModel) {
		this.typeModel = typeModel;
	}

	public AssistantAttributeTypeService getAttributeTypeService() {
		return attributeTypeService;
	}

	public void setAttributeTypeService(
			AssistantAttributeTypeService attributeTypeService) {
		this.attributeTypeService = attributeTypeService;
	}

	public AssistantAttributeService getAttributeService() {
		return attributeService;
	}

	public void setAttributeService(AssistantAttributeService attributeService) {
		this.attributeService = attributeService;
	}

	public PBaseMaterialAssistantattribute getAttributeModel() {
		return attributeModel;
	}

	public void setAttributeModel(PBaseMaterialAssistantattribute attributeModel) {
		this.attributeModel = attributeModel;
	}

	public String[] getRowlist() {
		return rowlist;
	}

	public void setRowlist(String[] rowlist) {
		this.rowlist = rowlist;
	}

	public List<PBaseMaterialAssistantattribute> getList() {
		return list;
	}

	public void setList(List<PBaseMaterialAssistantattribute> list) {
		this.list = list;
	}

	public String attributeBasicSelect() throws Throwable {
//		PBaseMaterialAssistantattribute model = new PBaseMaterialAssistantattribute();
		list = attributeService.getAllAssistantAttribute();
		FORWARD = "success";

		return FORWARD;
	}

	public String showAttributeBasicList() throws Throwable {
		list = attributeService.getAssistantattributeByTypeId(assistantAttributeTypeId);
		FORWARD = "success";

		return FORWARD;
	}
	
	
	public String showAddAttributeBasic() throws Throwable {
		
		FORWARD = "success";

		return FORWARD;
	}

	public String getAttributeBasicByCondition() throws Throwable {
		list = attributeService.getAssistantAttributeByCondition(attributeModel);
		FORWARD = "success";

		return FORWARD;
	}

	public String addAttributeBasic() throws Throwable {
		attributeService.addAssistantAttribute(attributeModel);
		FORWARD = "success";

		return FORWARD;
	}

	public String showEditAttributeBasic() throws Throwable {
		attributeModel = attributeService.getAssistantattributeById(Integer
				.valueOf((String) rowlist[0]));
		typeModel = attributeTypeService.getAttributeTypeById(attributeModel
				.getPBaseMaterialAssistantattributetypeId());
		FORWARD = "success";

		return FORWARD;
	}

	public String editAttributeBasic() throws Throwable {
		attributeService.updateAssistantAttribute(attributeModel);
		FORWARD = "success";

		return FORWARD;
	}
	
	public String deleteAttributeBasic() throws Throwable {
		attributeService.deleteAssistantAttribute(rowlist);
		FORWARD = "success";

		return FORWARD;
	}
}
